package com.jsgt.greekfire.ui.wallet.export

import android.view.View
import com.fhx.core.goToActivity
import com.jsgt.greekfire.R
import com.jsgt.greekfire.base.BaseBackgroundActivity
import com.jsgt.greekfire.ui.me.backup.BackupTipsDialog
import kotlinx.android.synthetic.main.activity_export_key.*

class ExportKeyActivity : BaseBackgroundActivity(), View.OnClickListener {

    private val tipsDialog: BackupTipsDialog by lazy { BackupTipsDialog() }

    private var identityId = -1

    override fun getLayoutId(): Int {
        return R.layout.activity_export_key
    }

    override fun main() {
        back.setOnClickListener(this)
        txvBackupNow.setOnClickListener(this)

        identityId = intent.getIntExtra("identityId", -1)
        if (identityId == -1) {
            finish()
        }

        tipsDialog.okListener = {
            goToActivity<PrivateKeyActivity> {
                putExtra("identityId", identityId)
            }
            onBackPressed()
            overridePendingTransition(R.anim.fade_in, R.anim.fade_out)
        }
    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.back -> {
                onBackPressed()
            }
            R.id.txvBackupNow -> {
//                showInputPwdDialog()
                tipsDialog.show(supportFragmentManager, "tips")
            }
        }
    }
}